package com.example.module_service.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_common.view.entity.DeviceEntity
import com.example.lib_common.view.entity.NoticeEntity
import com.example.module_service.R

class DeviceAdapter:BaseQuickAdapter<DeviceEntity,BaseViewHolder>(R.layout.item_device) {
    override fun convert(holder: BaseViewHolder, item: DeviceEntity) {
        holder.getView<TextView>(R.id.tvdevicetype).text="设备类别:${item.deviceType}"
        holder.getView<TextView>(R.id.tvinstalllocation).text="安装地点: ${item.installationLocation}"

        holder.getView<TextView>(R.id.tv_fault_rate).text="故障率:   ${item.failureRate*10}%"
        if(item.status=="正常"){
            holder.getView<TextView>(R.id.tv_status).text=item.status
            holder.getView<TextView>(R.id.tv_status).setBackgroundResource(com.example.lib_common.R.drawable.shape_solid_circleblue)
        }else if (item.status=="故障"){
            holder.getView<TextView>(R.id.tv_status).text=item.status
            holder.getView<TextView>(R.id.tv_status).setBackgroundResource(com.example.lib_common.R.drawable.shape_solid_circcleorange)
        }
    }
}